﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:GravityAppsMandelkowMetroCharts;assembly=GravityAppsMandelkowMetroCharts">
    <local:DoubleToGridLengthPercent x:Key="doubleToGridLengthPercent"/>
    <local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    
    <local:ResourceDictionaryCollection x:Key="DefaultPalette">
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush1" Color="#FF007C9C" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush2" Color="#FF019FCC" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush3" Color="#FF8FCD3E" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush4" Color="#FF82B93A" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush5" Color="#FF638A2D" />
        </ResourceDictionary>      
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush6" Color="#FFE3AAD6" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush7" Color="#FF4EA2CF" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush8" Color="#FFFF73AB" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush9" Color="#FFFF7D7D" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush10" Color="#FF6685A2" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush11" Color="#FF1D97E3" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush12" Color="#FF61B7EB" />
        </ResourceDictionary>
        <ResourceDictionary>
            <SolidColorBrush x:Key="Brush13" Color="#FFD88BC7" />
        </ResourceDictionary>
    </local:ResourceDictionaryCollection>

    <SolidColorBrush x:Key="ChartBackground" Color="#99FFFFFF" />
    <SolidColorBrush x:Key="ChartForeground" Color="#FF666666" />

    <Style x:Key="BaseTextStyle" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="Segoe UI" />
        <Setter Property="FontSize" Value="9" />
    </Style>
    <Style x:Key="ChartTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextStyle}">
        <Setter Property="FontSize" Value="26"/>
        <Setter Property="FontFamily" Value="Segoe UI Light"/>
        <Setter Property="FontWeight" Value="Light"/>
    </Style>
    <Style x:Key="ChartSubTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextStyle}">
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="FontWeight" Value="Light"/>
        <Setter Property="FontFamily" Value="Segoe UI Light"/>
        <Setter Property="Opacity" Value="0.75"/>
    </Style>
    <Style x:Key="SeriesTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextStyle}">
        <Setter Property="FontSize" Value="16" />
        <Setter Property="FontWeight" Value="Light"/>
        <Setter Property="Opacity" Value="0.75"/>
    </Style>
    
    <Style x:Key="SeriesTextStyle" TargetType="TextBlock">
        <Setter Property="TextAlignment" Value="Center" />
    </Style>
    <Style x:Key="NumberStyle" TargetType="TextBlock" >
        <Setter Property="TextAlignment" Value="Center" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Margin" Value="2 0 2 0" />
        <Setter Property="Opacity" Value="0.75" />
    </Style>
    <Style x:Key="LeftNumbers" TargetType="TextBlock" >
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="Opacity" Value="0.5" />
        <Setter Property="Margin" Value="3 1 3 1" />
    </Style>
    
    <Style TargetType="local:ChartTitle">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartTitle">
                    <StackPanel Margin="0 0 0 20" HorizontalAlignment="Left">
                        <TextBlock Text="{TemplateBinding Title}" Style="{StaticResource ChartTitleStyle}" />
                        <TextBlock Text="{TemplateBinding SubTitle}" Style="{StaticResource ChartSubTitleStyle}" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MinimalWidthTextBlock">        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MinimalWidthTextBlock">
                    <Border x:Name="PART_Border" HorizontalAlignment="Stretch" BorderThickness="0" Margin="0" >
                        <TextBlock x:Name="PART_TextBlock" VerticalAlignment="Center"  HorizontalAlignment="Right" TextWrapping="Wrap" Text="{TemplateBinding Text}" Style="{TemplateBinding TextBlockStyle}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:AutoSizeTextBlock">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AutoSizeTextBlock">
                    <Border x:Name="PART_Border" HorizontalAlignment="Stretch" BorderThickness="0" Margin="0">
                        <TextBlock x:Name="PART_TextBlock" VerticalAlignment="Center" Margin="5 0 5 0"  Opacity="1" HorizontalAlignment="Center" Text="{TemplateBinding Text}" Style="{TemplateBinding TextBlockStyle}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>    

    <Style TargetType="local:ChartLegendItem">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartLegendItem">
                    <StackPanel Orientation="Horizontal" Margin="0 0 10 5">
                        <Border Width="10" Height="20" Background="{TemplateBinding ItemBrush}" Margin="0 0 5 0" />
                        <TextBlock FontSize="{TemplateBinding FontSize}" VerticalAlignment="Center" Text="{TemplateBinding Caption}"></TextBlock>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:PiePieceLabel">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PiePieceLabel">
                    <Border>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{TemplateBinding Caption}" />
                            <TextBlock Text="{TemplateBinding Value}" />
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FadingListViewStyle" TargetType="local:FadingListView">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="BorderThickness" Value="0" />
        <!--
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="ContentPresenter">
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                </Style>
            </Setter.Value>
        </Setter>
        -->
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0" />
    </Style>

    <Style TargetType="local:ColumnPiece">
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ColumnPiece">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <!--<TextBlock Grid.Row="0" Visibility="{Binding Path=IsHeightExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}" Text="{Binding Path=Value}" Style="{StaticResource NumberStyle}" VerticalAlignment="Bottom" Foreground="Black" HorizontalAlignment="Stretch"  />-->
                        <local:AutoSizeTextBlock Grid.Row="0" Visibility="{Binding Path=IsHeightExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}"  Text="{Binding Path=Value}" TextBlockStyle="{StaticResource NumberStyle}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
                        <Border Grid.Row="1" x:Name="Slice" Width="auto" Height="auto" MinWidth="2" ToolTipService.ToolTip="{Binding Path=FormattedValue}">
                            <Grid>
                                <Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                <Border x:Name="SelectionHighlight" Background="{Binding Path=SelectedBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0" />
                                <!--<TextBlock  x:Name="MainTextBlock" Visibility="{Binding Path=IsHeightExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}" Text="{Binding Path=Value}" Foreground="White" Style="{StaticResource NumberStyle}" VerticalAlignment="Top" HorizontalAlignment="Stretch"  />-->
                                <local:AutoSizeTextBlock x:Name="MainTextBlock" Text="{Binding Path=Value}" TextBlockStyle="{StaticResource NumberStyle}" VerticalAlignment="Top" Foreground="White" HorizontalAlignment="Stretch" />
                            </Grid>
                        </Border>
                       
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="StackedColumnPiece" TargetType="local:ColumnPiece">
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ColumnPiece">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Grid.Row="1" x:Name="Slice" Width="auto" Height="auto" MinWidth="2" ToolTipService.ToolTip="{Binding Path=FormattedValue}" >
                            <Grid>
                                <Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                <Border x:Name="SelectionHighlight" Background="{Binding Path=SelectedBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0"/>
                                <local:AutoSizeTextBlock Text="{Binding Path=Value}" TextBlockStyle="{StaticResource NumberStyle}" VerticalAlignment="Center" Foreground="White" HorizontalAlignment="Stretch" />
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ChartLegendItemStyle" TargetType="local:ChartLegendItem">
        <Setter Property="FontSize" Value="9" />
    </Style>

    <!-- Style for all charts-->
    <Style x:Key="BaseChartStyle" TargetType="local:ChartBase">
        <Setter Property="Background" Value="{StaticResource ChartBackground}" />
        <Setter Property="Foreground" Value="{StaticResource ChartForeground}" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="FontFamily" Value="Segoe UI"/>       
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="DefaultPalette" Value="{StaticResource DefaultPalette}" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="20" />
        <Setter Property="FontSize" Value="10" />
        <Setter Property="ChartLegendItemStyle" Value="{StaticResource ChartLegendItemStyle}" />        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartBase">
                    <Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Margin="{TemplateBinding Margin}"
                        Padding="{TemplateBinding Padding}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" x:Name="PART_ChartTitle" Visibility="{TemplateBinding ChartTitleVisibility}">
                                <local:ChartTitle Title="{TemplateBinding ChartTitle}" SubTitle="{TemplateBinding ChartSubTitle}" Style="{TemplateBinding ChartTitleStyle}" />
                            </Border>
                            <Border x:Name="PART_ChartAreaBorder" Grid.Row="1">
                                <local:ChartArea x:Name="PART_ChartArea" Foreground="{TemplateBinding Foreground}" Style="{TemplateBinding ChartAreaStyle}" ChartLegendItemStyle="{TemplateBinding ChartLegendItemStyle}"  ParentChart="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}" >
                                    <local:PlotterArea x:Name="PART_PlotterArea" Foreground="{TemplateBinding Foreground}" Style="{TemplateBinding PlotterAreaStyle}" ChartLegendItemStyle="{TemplateBinding ChartLegendItemStyle}" ParentChart="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                                </local:ChartArea>
                            </Border>
                            <Border x:Name="PART_Exception" Grid.Row="2">
                                <local:FadingListView ItemsSource="{TemplateBinding Exceptions}">
                                    <local:FadingListView.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding}" Foreground="Black" />
                                        </DataTemplate>
                                    </local:FadingListView.ItemTemplate>
                                </local:FadingListView>
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="local:Legend">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Legend">
                    <Border x:Name="LegendArea" Margin="0 10 0 0" >
                        <local:FadingListView ItemsSource="{TemplateBinding ItemsSource}" >
                            <local:FadingListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <local:CustomWrapPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </local:FadingListView.ItemsPanel>
                            <local:FadingListView.ItemTemplate>
                                <DataTemplate>
                                    <local:ChartLegendItem Style="{Binding Path=ChartLegendItemStyle, RelativeSource={RelativeSource Mode=TemplatedParent}}" Caption="{Binding Path=Caption}" ItemBrush="{Binding Path=ItemBrush}" />
                                </DataTemplate>
                            </local:FadingListView.ItemTemplate> 
                        </local:FadingListView>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  
    <Style x:Key="BarSeriesTextStyle" TargetType="TextBlock" BasedOn="{StaticResource SeriesTextStyle}">
        <Setter Property="TextAlignment" Value="Right" />
    </Style>

    <Style x:Key="BasePlotterAreaStyle" TargetType="local:PlotterArea">
        <Setter Property="Background" Value="#FFFFAA00" />
    </Style>

    <Style x:Key="ColumnChartChartAreaStyle" TargetType="local:ChartArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartArea">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.Column="1" Grid.Row="0" Width="1" Background="DarkGray" Opacity="0.5" VerticalAlignment="Stretch" />
                        <Border Grid.Column="2" Grid.Row="1" Height="1" Background="DarkGray" Opacity="0.5" HorizontalAlignment="Stretch" />
                        <Border Grid.Column="1" Grid.Row="1" Height="1" Width="1" Background="DarkGray" Opacity="0.5" />
                        <Grid x:Name="BackgroundLines" Grid.Column="2" Grid.Row="0" Canvas.ZIndex="-1">
                            <local:FadingListView Style="{StaticResource FadingListViewStyle}" ItemsSource="{Binding Path=GridLines, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:EvenlyDistributedRowGrid IsReverseOrder="true" Margin="0 10 0 0" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="DarkGray" Opacity="0.25" BorderThickness="0 1 0 0" Background="Transparent"  />
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>
                            <Grid.RenderTransform>
                                <TranslateTransform X="0" Y="-1" />
                            </Grid.RenderTransform>
                        </Grid>
                        <Border Grid.Column="2" Grid.Row="0" >
                            <ContentControl 
                                VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"    
                                Content="{TemplateBinding Content}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                        </Border>
                        <Grid x:Name="SeriesText"
                                      Grid.Column="2"      
                                      Grid.Row="2">
                            <local:FadingListView Style="{StaticResource FadingListViewStyle}" ItemsSource="{Binding Path=DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:ColumnSeriesPanel Margin="0 5 0 5" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <!--
                                        <Border>
                                            <TextBlock Style="{StaticResource SeriesTextStyle}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Stretch" Text="{Binding Path=Caption}" />
                                            <local:MinimalWidthTextBlock Width="{Binding Path=ActualWidth, ElementName=parentBorder}" TextBlockStyle="{StaticResource SeriesTextStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Path=Caption}" />
                                        </Border>
                                        -->
                                        <local:MinimalWidthTextBlock TextBlockStyle="{StaticResource SeriesTextStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Path=Caption}" />
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>      
                        </Grid>
                        <Grid x:Name="LeftLines" Grid.Column="0" Grid.Row="0">
                            <local:FadingListView HorizontalAlignment="Stretch"  Style="{StaticResource FadingListViewStyle}" ItemsSource="{Binding Path=GridLines, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:EvenlyDistributedRowGrid IsReverseOrder="true" Margin="0 10 2 0" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Top">
                                            <TextBlock Text="{Binding}" Style="{StaticResource LeftNumbers}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>
                            <Grid.RenderTransform>
                                <TranslateTransform X="0" Y="-8" />
                            </Grid.RenderTransform>
                        </Grid>
                        <Border x:Name="PART_LegendArea" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Visibility="{Binding Path=ParentChart.ChartLegendVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <local:Legend x:Name="PART_Legend" ChartLegendItemStyle="{TemplateBinding ChartLegendItemStyle}" ItemsSource="{Binding Path=ChartLegendItems, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ColumnChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource BasePlotterAreaStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PlotterArea">
                    <local:FadingListView   
                        x:Name="itemsPanel" 
                        Style="{StaticResource FadingListViewStyle}"
                        ItemsSource="{Binding Path=ParentChart.DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                        ItemTemplate="{TemplateBinding DataPointItemTemplate}">
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:EvenlyDistributedColumnsGrid Margin="0 10 0 0" />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>                        
                    </local:FadingListView>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
        
    <Style x:Key="ClusteredColumnChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource ColumnChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView Style="{StaticResource FadingListViewStyle}" x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="5 0 5 0" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:EvenlyDistributedColumnsGrid />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:ColumnPiece
                                    Background="{Binding Path=ItemBrush}"  
                                    SelectedBrush="{Binding Path=SelectedBrush}"  
                                    Percentage="{Binding Path=PercentageFromMaxDataPointValue}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:ColumnPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>                
            </Setter.Value>
        </Setter>        
    </Style>
    <Style x:Key="StackedColumnChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource ColumnChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView Style="{StaticResource FadingListViewStyle}" x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="5 0 5 0" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:StackedColumnsPanel />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:ColumnPiece
                                    Style="{StaticResource StackedColumnPiece}"
                                    Background="{Binding Path=ItemBrush}"                                                               
                                    Percentage="{Binding Path=PercentageFromMaxDataPointGroupSum}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:ColumnPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="StackedColumn100ChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource ColumnChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView Style="{StaticResource FadingListViewStyle}" x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="5 0 5 0" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:StackedColumnsPanel />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:ColumnPiece
                                    Style="{StaticResource StackedColumnPiece}"
                                    Background="{Binding Path=ItemBrush}"                                                               
                                    Percentage="{Binding Path=PercentageFromSumOfDataPointGroup}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:ColumnPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ClusteredColumnChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource ColumnChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource ClusteredColumnChartPlotterAreaStyle}" />
    </Style>
    <Style TargetType="local:StackedColumnChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource ColumnChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource StackedColumnChartPlotterAreaStyle}" />
    </Style>
    <Style TargetType="local:StackedColumn100Chart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource ColumnChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource StackedColumn100ChartPlotterAreaStyle}" />
    </Style>

    <Style TargetType="local:BarPiece">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BarPiece">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0" x:Name="Slice" Width="auto" Height="auto" MinHeight="2" ToolTipService.ToolTip="{Binding Path=FormattedValue}" >
                            <Grid>                               
                                <Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                <Border x:Name="SelectionHighlight" Background="{Binding Path=SelectedBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0"/>
                                <local:AutoSizeTextBlock x:Name="MainTextBlock" Text="{Binding Path=Value}" TextBlockStyle="{StaticResource NumberStyle}" VerticalAlignment="Stretch" Foreground="White" HorizontalAlignment="Right" />
                            </Grid>
                        </Border>
                        <local:AutoSizeTextBlock Grid.Column="1" Visibility="{Binding Path=IsWidthExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}" Text="{Binding Path=Value}" TextBlockStyle="{StaticResource NumberStyle}" VerticalAlignment="Center" HorizontalAlignment="Left" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="StackedBarPiece" TargetType="local:BarPiece">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:BarPiece">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Slice" Width="auto" Height="auto" ToolTipService.ToolTip="{Binding Path=FormattedValue}" >
                            <Grid>
                                <Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                <Border x:Name="SelectionHighlight" Background="{Binding Path=SelectedBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0"/>
                                <TextBlock Foreground="White" Style="{StaticResource NumberStyle}" Text="{Binding Path=Value}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                            </Grid>
                        </Border>                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="PieChartChartAreaStyle" TargetType="local:ChartArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartArea">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <ContentControl Grid.Row="0" Content="{TemplateBinding Content}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />
                        <Border x:Name="Part_LegendArea" Grid.Row="1" Visibility="{Binding Path=ParentChart.ChartLegendVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <local:Legend x:Name="Part_Legend" ChartLegendItemStyle="{TemplateBinding ChartLegendItemStyle}" ItemsSource="{Binding Path=ChartLegendItems, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="PieChartPlotterAreaStyle" TargetType="local:PlotterArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PlotterArea">
                    <local:FadingListView Style="{StaticResource FadingListViewStyle}" x:Name="list" DataContext="{Binding Path=ParentChart, RelativeSource={RelativeSource Mode=TemplatedParent}}"  ItemsSource="{Binding Path=DataPointGroups}">
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:UniformGridPanel Orientation="Horizontal" MinimalGridWidth="{Binding Path=PieMinimalSize}" DataContext="{Binding Path=DataContext, ElementName=list}" />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>   
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <Grid >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Border Grid.Row="0" Visibility="{Binding Path=ShowCaption, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <TextBlock Text="{Binding Path=Caption}" Style="{StaticResource SeriesTitleStyle}" />
                                    </Border>
                                    <Border Grid.Row="1" x:Name="canvasBorder" >
                                        <local:FadingListView Style="{StaticResource FadingListViewStyle}"
                                            x:Name="itemsControl" 
                                            VerticalAlignment="Stretch" 
                                            HorizontalAlignment="Stretch"             
                                            ItemsSource="{Binding Path=DataPoints}">
                                            <local:FadingListView.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="100" MinHeight="100" />
                                                </ItemsPanelTemplate>
                                            </local:FadingListView.ItemsPanel>
                                            <local:FadingListView.ItemTemplate>
                                                <DataTemplate>
                                                    <local:PiePiece
                                                        ParentChart="{Binding Path=ParentChart}"
                                                        Background="{Binding Path=ItemBrush}"
                                                        SelectedBrush="{Binding Path=SelectedBrush}"  
                                                        StartValue="{Binding Path=StartValue}"
                                                        Value="{Binding Path=Value}"
                                                        SumOfDataSeries="{Binding Path=SumOfDataPointGroup}"      
                                                        IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                                        IsSelected="{Binding Path=IsSelected}"
                                                        DoughnutInnerRadiusRatio="{Binding Path=ParentChart.InnerRadiusRatio}"
                                                        ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                                        ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}"
                                                        x:Name="pie">
                                                    </local:PiePiece>
                                                </DataTemplate>
                                            </local:FadingListView.ItemTemplate>
                                        </local:FadingListView>
                                    </Border>
                                </Grid>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:PieChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource PieChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource PieChartPlotterAreaStyle}" />
    </Style>

    <Style x:Key="RadialGaugeChartChartAreaStyle" TargetType="local:ChartArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartArea">
                    <Grid>
                        <ContentControl Content="{TemplateBinding Content}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RadialGaugeChartPlotterAreaStyle" TargetType="local:PlotterArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PlotterArea">
                    <local:FadingListView Style="{StaticResource FadingListViewStyle}" ItemsSource="{Binding Path=ParentChart.DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Border Grid.Row="0" Visibility="{Binding Path=ShowCaption, Converter={StaticResource BooleanToVisibilityConverter}}">
                                        <TextBlock Text="{Binding Path=Caption}" Style="{StaticResource SeriesTitleStyle}" />
                                    </Border>
                                    <local:FadingListView Style="{StaticResource FadingListViewStyle}"
                                                x:Name="itemsControl" 
                                                ItemsSource="{Binding Path=DataPoints}"
                                                Margin="5"
                                                Grid.Row="1">
                                        <local:FadingListView.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <!--<StackPanel Orientation="Horizontal" />-->
                                                <local:UniformGridPanel Orientation="Horizontal" MinimalGridWidth="150.0" />
                                            </ItemsPanelTemplate>
                                        </local:FadingListView.ItemsPanel>
                                        <local:FadingListView.ItemTemplate>
                                            <DataTemplate>   
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="*" />
                                                        <RowDefinition Height="auto" />                                                        
                                                    </Grid.RowDefinitions>                                                    
                                                    <local:RadialGaugePiece
                                                        Grid.Row="0"
                                                        Margin="5"
                                                        Background="{Binding Path=ItemBrush}"
                                                        SelectedBrush="{Binding Path=SelectedBrush}"  
                                                        Value="{Binding Path=Value}"
                                                        IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                                        IsSelected="{Binding Path=IsSelected}"
                                                        ClientWidth="180"
                                                        ClientHeight="180" 
                                                        x:Name="radial">
                                                     </local:RadialGaugePiece>
                                                    <Border Grid.Row="1" HorizontalAlignment="Center" Margin="0 0 0 10">
                                                        <TextBlock Text="{Binding Path=SeriesCaption}" />
                                                    </Border>
                                                </Grid>
                                            </DataTemplate>
                                        </local:FadingListView.ItemTemplate>
                                    </local:FadingListView>
                                </Grid>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:RadialGaugeChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource RadialGaugeChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource RadialGaugeChartPlotterAreaStyle}" />
    </Style>

    <Style x:Key="BarChartChartAreaStyle" TargetType="local:ChartArea">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ChartArea">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="20" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.Column="1" Grid.Row="0" Width="1" Background="DarkGray" Opacity="0.5"  />
                        <Border Grid.Column="2" Grid.Row="1" Height="1" Background="DarkGray" Opacity="0.5" />
                        <Border Grid.Column="1" Grid.Row="1" Height="1" Width="1" Background="DarkGray" Opacity="0.5" />
                        <Grid x:Name="BackgroundLines" 
                                      Grid.Column="2"
                                      Canvas.ZIndex="-1"                                      
                                      Grid.Row="0">
                            <local:FadingListView ItemsSource="{Binding Path=GridLines, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:EvenlyDistributedColumnsGrid Margin="0 0 10 0" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="DarkGray" Opacity="0.25"  BorderThickness="1 0 0 0" Background="Transparent"  />
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>
                            <Grid.RenderTransform>
                                <TranslateTransform X="-1" Y="0" />
                            </Grid.RenderTransform>
                        </Grid>
                        <ContentControl 
                            Grid.Column="2" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"     
                            Grid.Row="0" Content="{TemplateBinding Content}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                        <Grid x:Name="SeriesText" Grid.Column="0" Grid.Row="0">
                            <local:FadingListView ItemsSource="{Binding Path=DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:EvenlyDistributedRowGrid Margin="0 0 5 0" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <local:MinimalWidthTextBlock TextBlockStyle="{StaticResource BarSeriesTextStyle}" VerticalAlignment="Center" HorizontalAlignment="Stretch" Text="{Binding Path=Caption}" />
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>
                        </Grid>
                        <Grid x:Name="LeftLines" Grid.Column="2" Grid.Row="2">
                            <local:FadingListView ItemsSource="{Binding Path=GridLines, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                <local:FadingListView.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <local:EvenlyDistributedColumnsGrid Margin="10 0 2 0" />
                                    </ItemsPanelTemplate>
                                </local:FadingListView.ItemsPanel>
                                <local:FadingListView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel HorizontalAlignment="Right" Orientation="Vertical" VerticalAlignment="Top">
                                            <TextBlock Text="{Binding}" Style="{StaticResource LeftNumbers}" TextWrapping="Wrap" />
                                        </StackPanel>
                                    </DataTemplate>
                                </local:FadingListView.ItemTemplate>
                            </local:FadingListView>
                            <Grid.RenderTransform>
                                <TranslateTransform X="-8" Y="0" />
                            </Grid.RenderTransform>
                        </Grid>
                        <Border x:Name="PART_LegendArea" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Visibility="{Binding Path=ParentChart.ChartLegendVisibility, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <local:Legend x:Name="PART_Legend" ChartLegendItemStyle="{TemplateBinding ChartLegendItemStyle}" ItemsSource="{Binding Path=ChartLegendItems, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="BarChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource BasePlotterAreaStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PlotterArea">
                    <local:FadingListView   
                        x:Name="itemsPanel"                                                  
                        ItemsSource="{Binding Path=ParentChart.DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                        ItemTemplate="{TemplateBinding DataPointItemTemplate}">
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:EvenlyDistributedRowGrid Margin="0 0 10 0" />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                    </local:FadingListView>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="ClusteredBarChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource BarChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="0 5 0 5" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:EvenlyDistributedRowGrid />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:BarPiece
                                    Background="{Binding Path=ItemBrush}"   
                                    SelectedBrush="{Binding Path=SelectedBrush}"
                                    Percentage="{Binding Path=PercentageFromMaxDataPointValue}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:BarPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="StackedBarChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource BarChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="0 5 0 5" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:RowSeriesPanel />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:BarPiece
                                    Style="{StaticResource StackedBarPiece}"
                                    Background="{Binding Path=ItemBrush}"                                                               
                                    Percentage="{Binding Path=PercentageFromMaxDataPointGroupSum}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:BarPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="StackedBar100ChartPlotterAreaStyle" TargetType="local:PlotterArea" BasedOn="{StaticResource BarChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView x:Name="itemsControl" ItemsSource="{Binding Path=DataPoints}" Margin="0 5 0 5" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:RowSeriesPanel />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:BarPiece
                                    Style="{StaticResource StackedBarPiece}"
                                    Background="{Binding Path=ItemBrush}"                                                               
                                    Percentage="{Binding Path=PercentageFromSumOfDataPointGroup}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}" >
                                </local:BarPiece>
                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ClusteredBarChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource BarChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource ClusteredBarChartPlotterAreaStyle}" />
    </Style>
    <Style TargetType="local:StackedBarChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource BarChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource StackedBarChartPlotterAreaStyle}" />
    </Style>
    <Style TargetType="local:StackedBar100Chart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource BarChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource StackedBar100ChartPlotterAreaStyle}" />
    </Style>

    <!--  charting:PieDataPoint  -->
    <Style TargetType="local:PiePiece">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="White" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PiePiece">
                    <Canvas x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="RevealStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.5" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Shown">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Path x:Name="Slice" Data="{TemplateBinding Geometry}" ToolTipService.ToolTip="{Binding Path=FormattedValue}" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeMiterLimit="1" />
                        <Path x:Name="SelectionHighlight" Data="{TemplateBinding SelectionGeometry}" Fill="{Binding Path=SelectedBrush}" StrokeMiterLimit="2" IsHitTestVisible="False" Opacity="0" />
                        <Path x:Name="MouseOverHighlight" Data="{TemplateBinding MouseOverGeometry}" Fill="White" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                        <Path x:Name="LabelLine" Data="{TemplateBinding LineGeometry}" StrokeThickness="1" StrokeMiterLimit="1" Stroke="{TemplateBinding Foreground}"  IsHitTestVisible="False" />
                        <!--<local:PiePieceLabel x:Name="PART_Label" Value="{Binding Path=Value, RelativeSource={RelativeSource Mode=TemplatedParent}}" />-->
                        <!--<TextBlock x:Name="PART_Label" Style="{StaticResource NumberStyle}" Margin="2" Text="{Binding Path=Value}" />-->
                        <Border x:Name="PART_Label">
                            <TextBlock Style="{StaticResource NumberStyle}" Margin="2" Text="{Binding Path=Value}" />
                        </Border>                        
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:RadialGaugePiece">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="White" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:RadialGaugePiece">
                    <Grid Width="{TemplateBinding ClientWidth}" Height="{TemplateBinding ClientHeight}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="RevealStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.5" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Shown">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Canvas x:Name="Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Path x:Name="BackgroundCircleHighlight" Data="{TemplateBinding BackgroundGeometry}" Fill="{TemplateBinding Foreground}" Opacity="0.2"  StrokeMiterLimit="1" IsHitTestVisible="False" />
                            <Path x:Name="Slice" Data="{TemplateBinding Geometry}" ToolTipService.ToolTip="{Binding Path=FormattedValue}" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeMiterLimit="1" />
                            <Path x:Name="SelectionHighlight" Data="{TemplateBinding SelectionGeometry}" Fill="{Binding Path=SelectedBrush}" StrokeMiterLimit="2" IsHitTestVisible="False" Opacity="0" />
                            <Path x:Name="MouseOverHighlight" Data="{TemplateBinding MouseOverGeometry}" Fill="White" StrokeMiterLimit="1" IsHitTestVisible="False" Opacity="0" />
                        </Canvas>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock LineStackingStrategy="BlockLineHeight" VerticalAlignment="Bottom" FontFamily="Segoe UI" Text="{Binding Path=FormattedAnimatedValue, RelativeSource={RelativeSource Mode=TemplatedParent}}" Foreground="{TemplateBinding Background}" FontWeight="Bold" FontSize="32" LineHeight="32" />
                            <TextBlock LineStackingStrategy="BlockLineHeight" VerticalAlignment="Bottom" FontFamily="Segoe UI" Text="%" FontWeight="Bold" LineHeight="32" FontSize="18" Foreground="{TemplateBinding Background}" />
                        </StackPanel>
                    </Grid>                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ToolTip">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Border Name="Border"
                        CornerRadius="4"
                        Background="White"
                        BorderBrush="Black"
                        BorderThickness="1"
                        Width="{TemplateBinding Width}"
                        Height="{TemplateBinding Height}">
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Text="{Binding Path=Caption}"></TextBlock>
                            <TextBlock>:</TextBlock>
                            <TextBlock Text="{Binding Path=Value}"></TextBlock>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!--gravity Apps charts-->

    <Style x:Key="GAScatterBulletStyle" TargetType="Rectangle" >
        <Setter Property="Height" Value="5"></Setter>
        <Setter Property="Width" Value="5"></Setter>
        <Setter Property="RadiusX" Value="2.5"></Setter>
        <Setter Property="RadiusY" Value="2.5"></Setter>
        <Setter Property="Fill" Value="Aquamarine"></Setter>
        <!--set to any value to have it filled, leav blank for line only, the value is ignored-->
    </Style>

    <Style x:Key="GANumberStyle" TargetType="TextBlock" >
        <Setter Property="TextAlignment" Value="Center" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Margin" Value="2 0 2 0" />
        <Setter Property="Opacity" Value="0.75" />
    </Style>

    <Style x:Key="GAScatterNumberStyle" TargetType="local:AutoSizeTextBlock">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:AutoSizeTextBlock">
                    <Border x:Name="PART_Border" HorizontalAlignment="Stretch" BorderThickness="0" Margin="0">
                        <TextBlock x:Name="PART_TextBlock" VerticalAlignment="Center" Margin="0 5 0 5"  
                                   Opacity="1" HorizontalAlignment="Center"
                                   Text="{TemplateBinding Text}" Style="{StaticResource GANumberStyle}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="GAMultipleSeriesScatterChartPlotterAreaStyle" 
           TargetType="local:PlotterArea" 
           BasedOn="{StaticResource BasePlotterAreaStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PlotterArea">
                    <!-- fading list of items -defined by DataPointItemTemplate, provided by ClusteredColumnChartPlotterAreaStyle-->
                    <!-- bound to baseChartStyle Datapoints groups-->
                    <local:FadingListView   
                        x:Name="itemsPanel" 
                        Style="{StaticResource FadingListViewStyle}"
                        ItemsSource="{Binding Path=ParentChart.DataPointGroups, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                        ItemTemplate="{TemplateBinding DataPointItemTemplate}">
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:GASingleColumnsGrid Margin="0 10 0 0">
                                </local:GASingleColumnsGrid>
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                    </local:FadingListView>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="local:GAScatterPiece">
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:GAScatterPiece">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="MouseOverHighlight" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SelectionHighlight" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <!--<TextBlock Grid.Row="0" Visibility="{Binding Path=IsHeightExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}" Text="{Binding Path=Value}" Style="{StaticResource NumberStyle}" VerticalAlignment="Bottom" Foreground="Black" HorizontalAlignment="Stretch"  />-->
                        <local:AutoSizeTextBlock Grid.Row="0" Visibility="{Binding Path=IsHeightExceedsSpace, ElementName=MainTextBlock, Converter={StaticResource BooleanToVisibilityConverter}}"  Text="{Binding Path=Value}" Style="{StaticResource GAScatterNumberStyle}" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
                        <!--<Border Grid.Row="1" x:Name="Slice" Width="auto" Height="auto" MinWidth="2" ToolTipService.ToolTip="{Binding Path=FormattedValue}">-->
                        <Border Grid.Row="1" x:Name="Slice" Width="auto" Height="auto" MinWidth="2" >
                            <Grid>
                                <Rectangle x:Name="Bullet" Style="{StaticResource GAScatterBulletStyle}" HorizontalAlignment="Center" VerticalAlignment="Top"  ToolTipService.ToolTip="{Binding Path=FormattedValue}" Fill="{TemplateBinding Background}"></Rectangle>
                                <Border  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                <Rectangle x:Name="SelectionHighlight" Style="{StaticResource GAScatterBulletStyle}" HorizontalAlignment="Center" VerticalAlignment="Top"  ToolTipService.ToolTip="{Binding Path=FormattedValue}" ></Rectangle>
                                <!--<Border x:Name="SelectionHighlight" Background="{Binding Path=SelectedBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0"/>-->
                                <local:AutoSizeTextBlock x:Name="MainTextBlock" Text="{Binding Path=Value}" Style="{StaticResource GAScatterNumberStyle}" VerticalAlignment="Top"  HorizontalAlignment="Stretch" />
                                <!-- was textBlockStyle-->

                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="GAScatterChartPlotterAreaStyle" 
           TargetType="local:PlotterArea"
           BasedOn="{StaticResource GAMultipleSeriesScatterChartPlotterAreaStyle}">
        <Setter Property="DataPointItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:FadingListView  Style="{StaticResource FadingListViewStyle}" 
                                           x:Name="itemsControl" 
                                           ItemsSource="{Binding Path=DataPoints}" 
                                           Margin="5 0 5 0" >
                        <local:FadingListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <local:EvenlyDistributedColumnsGrid />
                            </ItemsPanelTemplate>
                        </local:FadingListView.ItemsPanel>
                        <local:FadingListView.ItemTemplate>
                            <DataTemplate>
                                <local:GAScatterPiece
                                    Background="{Binding Path=ItemBrush}"  
                                    SelectedBrush="{Binding Path=SelectedBrush}"  
                                    Percentage="{Binding Path=PercentageFromMaxDataPointValue}"                                                                                                 
                                    IsClickedByUser="{Binding Path=IsClickedByUser, Mode=TwoWay}"
                                    IsSelected="{Binding Path=IsSelected}"
                                    ClientWidth="{Binding Path=RealWidth, ElementName=itemsControl}"
                                    ClientHeight="{Binding Path=RealHeight, ElementName=itemsControl}"
                                    >
                                </local:GAScatterPiece>


                            </DataTemplate>
                        </local:FadingListView.ItemTemplate>
                    </local:FadingListView>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    


    <Style TargetType="local:GAScatterChart" BasedOn="{StaticResource BaseChartStyle}">
        <Setter Property="ChartAreaStyle" Value="{StaticResource ColumnChartChartAreaStyle}" />
        <Setter Property="PlotterAreaStyle" Value="{StaticResource GAScatterChartPlotterAreaStyle}" />
    </Style>

</ResourceDictionary>

